package thread;

public class Demo11 {

    private static long count = 0;
    public static void main(String[] args) throws InterruptedException {
        Thread t1 = new Thread(()->{
            for (int i = 0; i < 5000; i++) {
                count++;
            }
        });

        Thread t2 = new Thread(()->{
            for (int i = 0; i < 5000; i++) {
                count++;
            }
        });

        t1.start();
        t2.start();

        ///main阻塞等待t1和t2
        t1.join();
        t2.join();

        //这样会出现bug，由于线程并发执行导致出现问题，改成串行就好了
        //即为
        //t1.start();
        //t1.join();
        System.out.println(count);
    }
}
